#!/usr/bin/env python
import numpy as np
from glob import glob
import sys
from astropy.io import fits

qe_dir = glob(sys.argv[1]+"/qe*")[0]
dark_dirs = glob(sys.argv[1]+"/dark*")
qe_files = glob(qe_dir+"/*.fits")
exp_time = []
qe_time = []
dark_time = []

for f in qe_files:
    exp_time.append(fits.open(f)[0].header['EXPTIME'])
    qe_time.append(fits.open(f)[0].header['DARKTIME'])
for d in dark_dirs:
    #print("d",d)
    dark_f = glob(d+"/*.fits")[0]
    dark_time.append(fits.open(dark_f)[0].header['DARKTIME'])
print("qe_exptime",np.sort(np.array(exp_time)))
print("qe_darktime",np.sort(np.array(dark_time)))   
print("qetime",np.unique(np.array(qe_time))) 
for i in range(len(dark_time)):
    d = dark_dirs[i]
    dark_f = glob(d+"/*.fits")[0]
    print(dark_f,dark_time[i])
